package com.lmx;

import javax.servlet.Filter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

import com.fasterxml.jackson.databind.ObjectMapper;

import io.katharsis.dispatcher.RequestDispatcher;
import io.katharsis.queryParams.QueryParamsBuilder;
import io.katharsis.resource.registry.ResourceRegistry;
import io.katharsis.spring.boot.JacksonConfiguration;
import io.katharsis.spring.boot.JsonLocatorConfiguration;
import io.katharsis.spring.boot.KatharsisRegistryConfiguration;
import io.katharsis.spring.boot.KatharsisSpringBootProperties;
import io.katharsis.spring.boot.QueryParamsBuilderConfiguration;
import io.katharsis.spring.boot.RequestDispatcherConfiguration;

@Configuration
@Import({RequestDispatcherConfiguration.class,
        QueryParamsBuilderConfiguration.class,
    JacksonConfiguration.class,
    JsonLocatorConfiguration.class,
    KatharsisRegistryConfiguration.class})
@EnableConfigurationProperties(KatharsisSpringBootProperties.class)
public class KathExtendConfig {

    @Autowired
    private KatharsisSpringBootProperties properties;

    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private ResourceRegistry resourceRegistry;

    @Autowired
    private RequestDispatcher requestDispatcher;

    @Autowired
    private QueryParamsBuilder queryParamsBuilder;

    @Bean
    public Filter springBootSampleKatharsisFilter() {
        return new KathExtendFilter(objectMapper, queryParamsBuilder, resourceRegistry, requestDispatcher, properties.getPathPrefix());
    }
}


